package com.wanmait.schedule.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.schedule.entity.StudentChange;
import com.wanmait.schedule.mapper.StudentChangeMapper;
import com.wanmait.schedule.service.StudentChangeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 学生调班表 服务实现类
 * </p>
 *
 * @author wanmait
 * @since 2022-12-05
 */
@Service
public class StudentChangeServiceImpl extends ServiceImpl<StudentChangeMapper, StudentChange> implements StudentChangeService {

    @Resource
    private StudentChangeMapper studentChangeMapper;

//分页 模糊搜索
    @Override
    public PageInfo<StudentChange> list(StudentChange studentChange, Integer pageNum) {
        if(pageNum==null){
            pageNum=1;
        }
        PageHelper.startPage(pageNum,6);
//        LambdaQueryWrapper<StudentChange> queryWrapper =new LambdaQueryWrapper<>();
//
//        queryWrapper.like(StringUtils.isNotBlank(studentChange.getStudent().getName()),StudentChange::getStudent,studentChange.getStudent());
//        queryWrapper.like(StringUtils.isNotBlank(studentChange.getContent()),StudentChange::getContent,studentChange.getContent());
//        queryWrapper.like(StringUtils.isNotBlank(studentChange.getNewSchedule()),StudentChange::getNewSchedule,studentChange.getNewSchedule());
//        queryWrapper.like(StringUtils.isNotBlank(studentChange.getOldSchedule()),StudentChange::getOldSchedule,studentChange.getOldSchedule());
//        queryWrapper.like(StringUtils.isNotBlank(studentChange.getTeacher().getName()),StudentChange::getTeacher,studentChange.getTeacher());
//        queryWrapper.like(StringUtils.isNotBlank(studentChange.getClass().getName()),StudentChange::getClass,studentChange.getClass());
        List<StudentChange> studentChanges=studentChangeMapper.Find(studentChange);
        PageInfo<StudentChange> pageInfo= new PageInfo<>(studentChanges,11);
        return pageInfo;
    }

    @Override
    public List<StudentChange> findAll() {
        return studentChangeMapper.findAll();
    }

    @Override
    public StudentChange findByClassId(Integer id) {
        return studentChangeMapper.findByClassId(id);
    }
}
